package com.bootdo.clouddo.utils;

import java.util.Random;

public class RandomUtil {
  private static final String RANDOM_STR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  private static final Random RANDOM = new Random();

  public RandomUtil() {
  }

  public static String getRandomStr() {
    return getRandomStr(16);
  }

  public static String getRandomStr(Integer length) {
    StringBuilder sb = new StringBuilder();

    for(int i = 0; i < length; ++i) {
      sb.append("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".charAt(RANDOM.nextInt("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".length())));
    }

    return sb.toString();
  }

  public static String getRandomNumStr(Integer length) {
    StringBuilder sb = new StringBuilder();

    for(int i = 0; i < length; ++i) {
      sb.append("0123456789".charAt(RANDOM.nextInt("0123456789".length())));
    }
    return sb.toString();
  }
}
